package com.zkthink.ceres.member.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.zkthink.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Map;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.zkthink.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 会员标签
 * 
 * </p>
 *
 * @author kellen
 * @since 2020-07-12
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "ceres_member_tag",autoResultMap=true)
@ApiModel(value = "MemberTag", description = "会员标签")
@AllArgsConstructor
public class MemberTag extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 标签名称
     */
    @ApiModelProperty(value = "标签名称")
    @NotEmpty(message = "标签名称不能为空")
    @Length(max = 300, message = "标签名称长度不能超过300")
    @TableField(value = "name", condition = LIKE)
    @Excel(name = "标签名称")
    private String name;

    /**
     * 1手动标签 2自动标签
     */
    @ApiModelProperty(value = "1手动标签 2自动标签")
    @NotNull(message = "1手动标签 2自动标签不能为空")
    @TableField("type")
    @Excel(name = "1手动标签 2自动标签")
    private Integer type;

    /**
     * 满足条件 1满足任意一个 2满足所有
     */
    @ApiModelProperty(value = "满足条件 1满足任意一个 2满足所有")
    @NotNull(message = "满足条件 1满足任意一个 2满足所有不能为空")
    @TableField("meet_condition")
    @Excel(name = "满足条件 1满足任意一个 2满足所有")
    private Integer meetCondition;


    /**
     * 具体的条件配置
     */
    @ApiModelProperty(value = "具体的条件配置")
    @NotEmpty(message = "具体的条件配置不能为空")
    @Length(max = 1000, message = "具体的条件配置长度不能超过1000")
    @TableField(value = "config", condition = LIKE,typeHandler = FastjsonTypeHandler.class)
    @Excel(name = "具体的条件配置")
    private Map<String,Object> config;

    /**
     * 是否删除 0否 1是
     */
    @ApiModelProperty(value = "是否删除 0否 1是")
    @NotNull(message = "是否删除 0否 1是不能为空")
    @TableField("is_delete")
    @Excel(name = "是否删除 0否 1是")
    @TableLogic
    private Integer isDelete;


    @TableField(exist = false)
    private Long tagCount = 0L;



    @Builder
    public MemberTag(Long id, LocalDateTime createTime, LocalDateTime updateTime, Long createUser,
        Long updateUser,
        String name, Integer type, Integer meetCondition, Map<String,Object> config,
        Integer isDelete) {
        this.id = id;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.createUser = createUser;
        this.updateUser = updateUser;
        this.name = name;
        this.type = type;
        this.meetCondition = meetCondition;
        this.config = config;
        this.isDelete = isDelete;
    }




}
